from django.urls import path, include
from rest_framework.routers import DefaultRouter
from rest_framework_simplejwt.views import TokenRefreshView
from .views import AuthViewSet, TechnicianViewSet, UserViewSet

# 创建路由器并注册视图集
auth_router = DefaultRouter()
auth_router.register(r'', AuthViewSet, basename='auth')

technician_router = DefaultRouter()
technician_router.register(r'', TechnicianViewSet, basename='technician')

user_router = DefaultRouter()
user_router.register(r'', UserViewSet, basename='user')

urlpatterns = [
    path('wx_login/', AuthViewSet.as_view({'post': 'wx_login'}), name='wx_login'),
    path('userinfo/', AuthViewSet.as_view({'get': 'userinfo'}), name='userinfo'),
    path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('technician/', include([
        path('certification/', TechnicianViewSet.as_view({'post': 'certification'}), name='technician_certification'),
    ])),
    path('user/', include([
        path('switch_role/', UserViewSet.as_view({'post': 'switch_role'}), name='switch_role'),
    ])),
]